/**
 * Copyright 2015 Qiyi Inc. All rights reserved.
 *
 * @file:   Channel.Dao.js
 * @path:   js-src/Channel/
 * @desc:   负责本模块的远程调用的静态对象
 * @author: jiegang@qiyi.com
 * @date:   2015-01-07
 */
qui(
    function(require, exports, module) {

        Channel.Dao = $.extend({}, EpgWeb.Dao, {

            // 频道添加
            setChannelAddData: function(data, callback) {
                var options = {
                    url: '/api/channel/create',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/channel/create');
            },

            // 频道修改
            setChannelModifyData: function(data, callback) {
                var options = {
                    url: '/api/channel/edit',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/channel/edit');
            },

            // 频道删除
            deleteChannelData: function(data, callback) {
                var options = {
                    url: '/api/channel/del',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/channel/del');
            },

            // 获取单个频道数据
            getSingleChannelData: function(data, callback) {
                var options = {
                    url: '/api/channel/get',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/channel/get');
            },

            // 获取分类
            getCategories: function(data, callback) {
                var options = {
                    url: '/api/redirect',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/redirect');
            },


            // 频道操作历史
            getOperateLog: function(data, callback) {
                var options = {
                    url: '/api/channel/loglist',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/channel/loglist');
            },

            //{control":0,"stream":0,"program":0}

            /*  
                program >0 节目单 直播流管理    
                stream >0 直播流管理  播控中心
                control > 0  播控中心 预约计划
                */

            // 获取频道操作权限
            getChannelAuth: function(data, callback) {
                var options = {
                    url: '/api/channel/menuShow',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/channel/menuShow');
            },

            // 获取某天节目单
            getProgramListByDay: function(data, callback) {
                var options = {
                    url: '/api/program/list',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/program/list');
            },

            // 获取某天节目单
            getPreviewStream: function(data, callback) {
                var options = {
                    url: '/api/channel/getPreviewStream',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/channel/getPreviewStream');
            },

            // 轮播台台号是否存在
            carouselTableNo: function(data, callback) {
                var options = {
                    url: '/api/channel/carouselTableNo',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/channel/carouselTableNo');
            },

            // 备播库调用第三方接口
            alternateOperation: function(data, callback) {
                var options = {
                    url: '/api/redirect',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/redirect');
            },

            getProgramMaxDuration: function (data, callback) {
                var options = {
                    url: '/api/program/maxDuration',
                    dataType: 'json',
                    data: data,
                    method: 'get',
                    success: function (data) {
                        callback.call(this, data)
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/program/maxDuration');
            }
        });
    }
);